<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="100px">
      <el-form-item label="学校名称" prop="schoolName">
        <el-input v-model="queryParams.schoolName" placeholder="请输入学校名称" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="学校简称" prop="schoolAliaeName">
        <el-input v-model="queryParams.schoolAliaeName" placeholder="请输入学校简称" clearable
          @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="教育层次" prop="levelOfEducation">
        <el-select v-model="queryParams.levelOfEducation" placeholder="请选择" clearable>
          <el-option v-for="dict in dict.type.level_of_education" :key="dict.value" :label="dict.label"
            :value="dict.value" />
        </el-select>
      </el-form-item>
      <el-form-item label="联系电话" prop="tel">
        <el-input v-model="queryParams.tel" placeholder="请输入联系电话" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="上线" prop="state">
        <el-select v-model="queryParams.state" placeholder="请选择" clearable>
          <el-option v-for="dict in dict.type.common_state" :key="dict.value" :label="dict.label" :value="dict.value" />
        </el-select>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>



    <el-table v-loading="loading" :data="schoolinfoList">
      <el-table-column label="id" align="center" prop="id" />
      <el-table-column label="联系人" align="center" prop="contacts" :show-overflow-tooltip="true" />
      <el-table-column label="学校全称" align="center" prop="schoolName" :show-overflow-tooltip="true" />
      <el-table-column label="学校简称" align="center" prop="schoolAliaeName" :show-overflow-tooltip="true" />
      <el-table-column label="机构" align="center" prop="orgName" :show-overflow-tooltip="true" />
      <el-table-column label="招生人数" align="center" prop="studentCapacity" :show-overflow-tooltip="true" />
      <el-table-column label="学校类型" align="center" prop="schoolType" :show-overflow-tooltip="true">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.school_type" :value="scope.row.schoolType" />
        </template>
      </el-table-column>
      <el-table-column label="教育层次" align="center" prop="levelOfEducation" :show-overflow-tooltip="true">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.level_of_education" :value="scope.row.levelOfEducation" />
        </template>
      </el-table-column>
      <el-table-column label="联系电话" align="center" prop="tel" :show-overflow-tooltip="true" />
      <el-table-column label="省、市、区" align="center" prop="provinceAndCityAndDistrict" :show-overflow-tooltip="true" />
      <el-table-column label="成立日期" align="center" prop="establishedDate" :show-overflow-tooltip="true">
      </el-table-column>
      <el-table-column label="上线" align="center" prop="state" :show-overflow-tooltip="true">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.common_state" :value="scope.row.state" />
        </template>
      </el-table-column>
    </el-table>

    <pagination v-show="total>0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize"
      @pagination="getList" />
  </div>
</template>

<script>
  import {
    listSchoolinfo,
    getSchoolinfo,
    delSchoolinfo,
    addSchoolinfo,
    updateSchoolinfo
  } from "@/api/bus_web/school/schoolinfo";

  import {
    mapState
  } from 'vuex';
  import store from "@/store";
  export default {
    name: "OrgSchoolinfo",
    dicts: ['common_state', 'level_of_education', 'school_type'],
    data() {
      return {

        //选中代理
        selectedAgentData: [],
        // 遮罩层
        loading: true,
        // 显示搜索条件
        showSearch: true,
        // 总条数
        total: 0,
        // 学校管理表格数据
        schoolinfoList: [],
        // 弹出层标题
        title: "",
        // 查询参数
        queryParams: {
          pageNum: 1,
          pageSize: 10,
          schoolName: null,
          schoolAliaeName: null,
          orgId: null,
          orgIdArray: [],
          orgName: null,
          schoolType: null,
          levelOfEducation: null,
          tel: null,
          introduce: null,
          province: null,
          city: null,
          district: null,
          address: null,
          state: null,
          queryProvinceAndCityAndDistrict: null,
        },
        // 表单参数
        form: {},
        // 表单校验
        rules: {

        }
      };
    },
    methods: {
      init(id) {
        this.queryParams.orgIdArray = []
        this.queryParams.orgIdArray.push(id)
        this.resetQuery()
      },
      /** 查询学校管理列表 */
      getList() {
        this.loading = true;
        listSchoolinfo(this.queryParams).then(response => {
          this.schoolinfoList = response.rows;
          this.total = response.total;
          this.loading = false;
        });
      },
      /** 搜索按钮操作 */
      handleQuery() {
        this.queryParams.pageNum = 1;
        this.getList();
      },
      /** 重置按钮操作 */
      resetQuery() {
        this.resetForm("queryForm");
        this.handleQuery();
      },
    }
  };
</script>
